import java.util.Scanner;

public class Work01 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int[] arr = {2021,2021,2021,2021,2021,2021,2021,2021,2021,2021};
        int last = 1;
        int num;
        for(int i = 1;;i++){
            //判断要拼的数字包含几个要消耗的卡片
            num = i;
            while(num  > 0){
                int kard = num % 10;
                if(arr[kard] == 0){
                    System.out.println(last);
                    return;
                }
                arr[kard]--;
                num /= 10;
            }
            last = i;
        }
    }
}
